package chapter07

/**
  * 元组,最多22个元素
  */
object Test10_Tuple {

  def main(args: Array[String]): Unit = {
    // 1.创建元组
    val tuple: (String, Int, Char, Boolean) = ("hello", 100, 'a', true)
    println(tuple)

    //2.获取元组
    println(tuple._4)
    println(tuple.productElement(0))

    // 3.遍历元组
    for (elem <- tuple.productIterator) {
      println(elem)
    }
    // 4.嵌套元组
    val mulTuple = (12, 0.3, "hello", (23, "scala", 29))
    println(mulTuple._4._2)
  }
}
